package io.renren.modules.labonin.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.labon.entity.LableonlineEntity;
import io.renren.modules.posinfo.entity.Utype1Entity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.labonin.entity.LableonlineinfoEntity;
import io.renren.modules.labonin.service.LableonlineinfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

@RestController
@RequestMapping("labonin/lableonlineinfo")
public class LableonlineinfoController {
    @Autowired
    private LableonlineinfoService lableonlineinfoService;

//    @GetMapping(value = "/iswork",produces = {"application/json;charset=UTF-8"})
//    public List<LableonlineinfoEntity> listIsWork(){
//        return lableonlineinfoService.listIsWork();
//    }
    // 5秒钟刷新一次
//    @Scheduled(cron = "0/5 * * * * ?")
@GetMapping(value = "/iswork",produces = {"application/json;charset=UTF-8"})
public List<Utype1Entity> listIsWork(){
    return lableonlineinfoService.listIsWork();
}



    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("labonin:lableonlineinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = lableonlineinfoService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{lableNo}")
    @RequiresPermissions("labonin:lableonlineinfo:info")
    public R info(@PathVariable("lableNo") Integer lableNo){
		LableonlineinfoEntity lableonlineinfo = lableonlineinfoService.getById(lableNo);

        return R.ok().put("lableonlineinfo", lableonlineinfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("labonin:lableonlineinfo:save")
    public R save(@RequestBody LableonlineinfoEntity lableonlineinfo){
		lableonlineinfoService.save(lableonlineinfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("labonin:lableonlineinfo:update")
    public R update(@RequestBody LableonlineinfoEntity lableonlineinfo){
		lableonlineinfoService.updateById(lableonlineinfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("labonin:lableonlineinfo:delete")
    public R delete(@RequestBody Integer[] lableNos){
		lableonlineinfoService.removeByIds(Arrays.asList(lableNos));

        return R.ok();
    }

}
